package com.ling.module1sbbyyds.controller.video;

import com.ling.sbbyyds.entity.video.VideoCommentLike;
import com.ling.sbbyyds.interaction.vo.commentvo.CommentVo;
import com.ling.module1sbbyyds.service.video.SbbVideoCommentService;
import com.ling.sbbyyds.interaction.ResultVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * 文章评论表(SbbComment)表控制层
 *
 * @author ling
 * @since 2022-07-23 17:48:09
 */
@RestController
@RequestMapping("api/video/comment")
public class SbbVideoCommentController {
    /**
     * 服务对象
     */
    @Resource
    private SbbVideoCommentService sbbVideoCommentService;

    /**
    * @Description: 发布评论
    * @author: ling
    * @date: 2022/7/24
    * @param commentVo:
    * @Return: com.ling.sbbyyds.interaction.ResultVo
    */
    @PostMapping("isLogin/publishComment")
    public ResultVo publishComment(@RequestBody @Validated CommentVo commentVo) throws IOException {
        return sbbVideoCommentService.publishComment(commentVo);
    }

    /**
    * @Description: 删除评论（只允许评论本人删除）
    * @author: ling
    * @date: 2022/7/24
    * @param commentId:
    * @Return: com.ling.sbbyyds.interaction.ResultVo
    */
    @GetMapping("isLogin/deleteComment")
    public ResultVo deleteComment(@RequestParam Long commentId){
        return sbbVideoCommentService.deleteComment(commentId);
    }

    /**
     * 是否点赞评论
     * @param commentLike
     * @param type 取消或点赞
     * @return
     */
    @PostMapping("isLogin/likeComment/{type}")
    public ResultVo likeComment(@RequestBody VideoCommentLike commentLike, @PathVariable("type") Boolean type){
        return sbbVideoCommentService.likeComment(commentLike,type);
    }


    /**
     * @Description: 查评论
     * @author: ling
     * @date: 2022/7/24
     * @param videoId: 视频id
     * @Return: com.ling.sbbyyds.interaction.ResultVo
     */
    @GetMapping("queryComment")
    public ResultVo queryComment(@RequestParam Long videoId){
        return sbbVideoCommentService.queryCommentV2(videoId);
    }

}

